//
//  HQMapMyLocationStyleModel.m
//  o_amap
//
//  Created by Q神 on 2021/4/15.
//

#import "HQMapMyLocationStyleModel.h"
#import "HQMapTools.h"
#import "UIColor+Hex.h"

@implementation HQMapMyLocationStyleModel

- (void)setMyLocationStyle:(MAMapView *)mapView withFlutterRegistrar:(nonnull NSObject<FlutterPluginRegistrar> *)reg {
    
    /// 自定义定位小蓝点
    MAUserLocationRepresentation *r = [[MAUserLocationRepresentation alloc] init];
    /// 精度圈是否显示，默认YES
    r.showsAccuracyRing = self.showsAccuracyRing;
    /// 是否显示方向指示(MAUserTrackingModeFollowWithHeading模式开启)。默认为YES
    r.showsHeadingIndicator = self.showsHeadingIndicator;
    /// 精度圈 填充颜色, 默认 kAccuracyCircleDefaultColor
    r.fillColor = [UIColor colorWithHexString:self.radiusFillColor];
    /// 精度圈 边线颜色, 默认 kAccuracyCircleDefaultColor
    r.strokeColor = [UIColor colorWithHexString:self.strokeColor];
    /// 精度圈 边线宽度，默认0
    r.lineWidth = self.strokeWidth;
    /// 定位点背景色，不设置默认白色
    r.locationDotBgColor = [UIColor colorWithHexString:self.locationDotBgColor];
    /// 定位点蓝色圆点颜色，不设置默认蓝色
    r.locationDotFillColor = [UIColor colorWithHexString:self.locationDotFillColor];
    /// 内部蓝色圆点是否使用律动效果, 默认YES
    r.enablePulseAnnimation = self.enablePulseAnnimation;
    /// 定位图标, 与蓝色原点互斥
    if ([[HQMapTools shareInstance] getAppPluginImageWithRegistrar:reg withImageName:self.myLocationIcon]) {
        HQMapTools *tools = [HQMapTools shareInstance];
        UIImage *img = [tools getAppPluginImageWithPath:[tools getAppPluginImageWithRegistrar:reg withImageName:self.myLocationIcon]];
        if (img) {
            r.image = img;
        }
    }
    [mapView updateUserLocationRepresentation:r];
    
    /// 是否显示用户位置
    mapView.showsUserLocation = self.showMyLocation;
    /// 设置导航模式为跟随
    mapView.userTrackingMode = MAUserTrackingModeFollow;
}

@end
